-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][NFC] Extract specialization constant's processing from sycl-post-link to SYCLPostLink library. #19022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sycl
Are you sure you want to change the base?
Conversation
…st-link to SYCLPostLink library. This change allows later reuse in the New Offloading Model and sycl-jit.
The interface of a function SmallVector<ModuleDesc> MDs;
Modified |= handleSpecializationConstants(MDs, Mode); If you have a better alternative for the function's interface let me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, just a few nits.
std::optional<SpecConstantsPass::HandlingMode> Mode, | ||
bool GenerateModuleDescWithDefaultSpecConsts, | ||
SmallVectorImpl<module_split::ModuleDesc> *NewModuleDescs) { | ||
assert((GenerateModuleDescWithDefaultSpecConsts ^ !NewModuleDescs) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite difficult to read. Could we rewrite this to something simpler?
Maybe something like:
assert((GenerateModuleDescWithDefaultSpecConsts ^ !NewModuleDescs) && | |
#ifdef NDEBUG | |
if (GenerateModuleDescWithDefaultSpecConsts) | |
assert(NewModuleDescs); | |
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it look to you now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks much better, thanks!!
|
||
Modified |= processSpecConstants(MMs[I]); | ||
} | ||
Modified |= handleSpecializationConstants( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of nits:
- Rename func as processSpecConsts
- The fourth argument can be &MMsWithDefaultSpecConsts and the selection can happen inside processSpecConsts
// Specialization constants processing consists of lowering and generation | ||
// of new module with spec consts replaced by default values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Specialization constants processing consists of lowering and generation | |
// of new module with spec consts replaced by default values. | |
// This file handles processing of metadata and intrinsics related to SYCL specialization constants and generates a | |
// new module with specialization constants replaced by default values. |
namespace llvm { | ||
namespace sycl { | ||
|
||
/// Handling consists of SpecConsts's lowering depending on the given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Handling consists of SpecConsts's lowering depending on the given | |
/// Metadata and intrinsics related to SYCL specialization constants are lowered depending on the given |
MAM.registerPass([&] { return PassInstrumentationAnalysis(); }); | ||
RunSpecConst.addPass(std::move(SCP)); | ||
|
||
// Perform the spec constant intrinsics transformation on resulting module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Perform the spec constant intrinsics transformation on resulting module. | |
// Perform the specialization constant intrinsics transformation on resulting module. |
} | ||
|
||
/// Function generates the copy of the given \p MD where all uses of | ||
/// Specialization Constants are replaced by corresponding default values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Specialization Constants are replaced by corresponding default values. | |
/// specialization constants are replaced by corresponding default values. |
PreservedAnalyses Res = MPM.run(NewMD->getModule(), MAM); | ||
NewMD->Props.SpecConstsMet = !Res.areAllPreserved(); | ||
assert(NewMD->Props.SpecConstsMet && | ||
"This property should be true since the presence of SpecConsts " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reword the error to be more precise?
"This property should be true since the presence of SpecConsts " | |
"SpecConstsMet should be true since the presence of SpecConsts " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. Minor changes requested.
Thanks
This change allows later reuse of specialization constant's processing in the New Offloading Model and sycl-jit.